﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Drawing;
using System.Data;
using System.Text;
using System.Windows.Forms;
using DevExpress.XtraEditors;
using BUS;
using DTO;
namespace GUI
{
    public partial class uc_TraCuuBaoHanh : DevExpress.XtraEditors.XtraUserControl
    {
        public uc_TraCuuBaoHanh()
        {
            InitializeComponent();
        }

        MobileBL mobilebl = new MobileBL();
        MobileDTO mobile = new MobileDTO();
        CustomerBL customerbl = new CustomerBL();
        CustomerDTO customer = new CustomerDTO();
        WarrantyBL warr = new WarrantyBL();
        private void gridView1_RowCellClick(object sender, DevExpress.XtraGrid.Views.Grid.RowCellClickEventArgs e)
        {
            mobile = mobilebl.Mobile_SelectByID(int.Parse(gridView1.GetRowCellValue(gridView1.FocusedRowHandle, "MobileID").ToString()));
            txtMaDT.Text = mobile.MobileID.ToString();
            txtTenDT.Text = mobile.Name;
            txtBaoHanh.Text = mobile.WarrantyTime.ToString();
            txtNgayMuaHang.Text = gridView1.GetRowCellValue(gridView1.FocusedRowHandle, "Date").ToString();
            customer = customerbl.Custummer_SelectByID(int.Parse(gridView1.GetRowCellValue(gridView1.FocusedRowHandle, "customerid").ToString()));
            txtHoTen.Text = customer.Name;
            txtMaKH.Text = customer.CustomerID.ToString();
            txtDiaChi.Text = customer.Address;
            txtSDT.Text = customer.Phone;
        }

        private void btnTimKiem_Click(object sender, EventArgs e)
        {
            if (txtNoiDungTK.Text != "")
            {
                gridTraCuuBH.DataSource = warr.Warranty_SelectByCustomerName(txtNoiDungTK.Text);
            }
        }
    }
}
